package com.giCompiler.util;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;
//import org.hibernate.tool.hbm2ddl.SchemaExport;

public class HibernateUtil { 

	private static final SessionFactory sessionFactory; 
   
	static { 
     
		try { 
	        
			Configuration cfg = new AnnotationConfiguration().configure();
			
//			Exporta o esquema da tabela para o Banco de Dados
//			SchemaExport schema = new SchemaExport(cfg);
//			schema.create(true, true);
			
			sessionFactory = cfg.buildSessionFactory();		
			
		} catch (Throwable ex) { 
	           
			System.out.println("Falha ao construir a SessionFactory!." + ex); 
			ex.printStackTrace();
			throw new ExceptionInInitializerError(ex); 
		      
		}  
	}  

	public static SessionFactory getSessionFactory() { 
        
		return sessionFactory; 
   
	} 
}
